package com.zzlzd.drp.domain;

import lombok.Data;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.*;
import java.util.List;

public interface StudyCodeRep extends JpaRepository<StudyCodeDto,Integer> {

    @Query(nativeQuery=true, value=" SELECT * FROM study_code WHERE uid = ?1 order by state ASC")
    public List<StudyCodeDto> getListByUid(Integer id);

    @Query(nativeQuery=true, value=" SELECT COUNT(id) FROM study_code WHERE uid = ?1 AND state = 0")
    public int getTrueListByUid(Integer id);

    @Query(nativeQuery=true, value=" SELECT * FROM study_code WHERE code_str = ?1 AND 1=1")
    StudyCodeDto getCode(String code);
}
